import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String arr1 = scanner.nextLine();
        String arr2 = scanner.nextLine();
        int len1 = arr1.length();
        int len2 = arr2.length();
        if(len1 != len2) {
            System.out.println("NO");
            return;
        }
        int[] hash1 = new int[200];
        int[] hash2 = new int[200];
        for(int i = 0; i < len1; i++) {
            hash1[arr1.charAt(i)]++;
            hash2[arr2.charAt(i)]++;
            if(hash1[arr1.charAt(i)] != hash2[arr2.charAt(i)]) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}
